package bm.com.project.server.project.controller;

import bm.com.framework.common.config.EnumRoute;
import bm.com.project.server.VerifyController;
import bm.com.project.server.common.dto.SearchBaseDTO;
import bm.com.project.server.project.dto.BmAddMemberDTO;
import bm.com.project.server.project.service.BmProjectMemberService;
import bm.com.framework.common.resp.ResultVO;
import bm.com.framework.common.unit.Tool;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(EnumRoute.ProjectRoute.BASE)
public class ProjectMemberController extends VerifyController {

    @Resource
    BmProjectMemberService bmProjectMemberService;

    @PostMapping(EnumRoute.ProjectRoute.Member.GET_LIST)
    public ResultVO getList(@RequestBody SearchBaseDTO queue){
        return bmProjectMemberService.getList(queue);
    }

    /**
     * 添加项目成员
     * @param bmAddMemberDTO
     * @return
     */
    @PostMapping(EnumRoute.ProjectRoute.Member.ADD)
    public ResultVO add(@RequestBody BmAddMemberDTO bmAddMemberDTO){
        return bmProjectMemberService.add(bmAddMemberDTO);
    }

    @PostMapping(EnumRoute.ProjectRoute.Member.DELETE)
    public ResultVO add(
            @RequestParam(name = "memberId") long memberId
    ){

        if (Tool.isLongEmpty(memberId)){
            return ResultVO.error("参数不能为空");
        }

        return bmProjectMemberService.delete(memberId);
    }
}
